<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    .parent{
      width:200px;
      height:200px;
      padding:50px;
      border:1px solid blue;
    }
    .son{
      width:200px;
      height:200px;
      border:1px solid red;
    }
  </style>
</head>
<body>
  <div id="app">
    <div class="parent">
      <div class="son" v-ceshi>123</div>
    </div>
  </div>
  <script src="js/vue.js"></script>
  <script>
    //第一阶段：指令绑定到对应的元素身上 bind
    //第二阶段：元素添加到DOM树当中 inserted
    Vue.directive('ceshi',{
      bind:function(el){
        console.log(el)
        console.log(el.parentNode)
      },
      inserted:function(el){
        console.log(el)
        console.log(el.parentNode)
      }
    })
    var vm = new Vue({
      el:'#app'
    })
  </script>
</body>
</html>